library(haven);library(interflex);library(car);library(vtable);library(xtable)

d <- read_dta("Study1YouGov.dta")

##Prepare variables for analysis
d$curb_treatment <- recode(d$stance_reorder_treatment,"1=NA;2=1;3=0")
d$statement_treatment <- recode(d$stance_reorder_treatment,"1=0;2=1;3=NA")
d$defend_treatment <- recode(d$stance_reorder_treatment,"1=0;2=NA;3=1")
quantile(d$legit, c((1/3), (2/3)),na.rm=T) 
d$legitTercile <- recode(d$legit,"0:0.4921501=1;0.4921502:0.7421501=2;0.7421502:1=3")

##Make Figure 1 (Main Text)
statement_overall <- t.test(subset(d,stance_reorder_treatment==1)$support_dv)
statement_nonpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$support_dv)
statement_copartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$support_dv)
statement_outpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$support_dv)
curb_overall <- t.test(subset(d,stance_reorder_treatment==2)$support_dv)
curb_nonpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$support_dv)
curb_copartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$support_dv)
curb_outpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$support_dv)
defend_overall <- t.test(subset(d,stance_reorder_treatment==3)$support_dv)
defend_nonpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$support_dv)
defend_copartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$support_dv)
defend_outpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$support_dv)
diff_overall <- t.test(subset(d,stance_reorder_treatment==2)$support_dv,subset(d,stance_reorder_treatment==3)$support_dv)
diff_nonpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$support_dv,subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$support_dv)
diff_copartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$support_dv,subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$support_dv)
diff_outpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$support_dv,subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$support_dv)
diff_overall_s <- t.test(subset(d,stance_reorder_treatment==2)$support_dv,subset(d,stance_reorder_treatment==1)$support_dv)
diff_nonpartisan_s <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$support_dv,subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$support_dv)
diff_copartisan_s <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$support_dv,subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$support_dv)
diff_outpartisan_s <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$support_dv,subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$support_dv)
diff_overall_ds <- t.test(subset(d,stance_reorder_treatment==3)$support_dv,subset(d,stance_reorder_treatment==1)$support_dv)
diff_nonpartisan_ds <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$support_dv,subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$support_dv)
diff_copartisan_ds <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$support_dv,subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$support_dv)
diff_outpartisan_ds <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$support_dv,subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$support_dv)

pdf("supportOmnibusMainNoOverallRR2.pdf",width=15,height=5,paper='special') 
par(mar=c(5.1,6, 4.1, 2.1),mfrow=c(1,3))
plot(c(.9,1,1.1),c(curb_nonpartisan$estimate,curb_copartisan$estimate,curb_outpartisan$estimate),ylab="Incumbent Support",
     col=c("#0072ce","#1e407c","darkgray"),
     main="Direct Effects",cex.main=3,xaxt="n", xlab="", xlim=c(.75,3.25),
     cex.axis=2,cex.lab=2.5,ylim=c(0,1),pch=c(19,15,17),cex=2)
mtext(at=c(1,2,3),text=c("Curb","Defend","Statement"),side=1,line=1.5,cex=1.4)
points(x=c(1.9,2,2.1),y=c(defend_nonpartisan$estimate,defend_copartisan$estimate,defend_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=.9,x1=.9,y0=curb_nonpartisan$conf.int[1],y1=curb_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=1,x1=1,y0=curb_copartisan$conf.int[1],y1=curb_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=1.1,x1=1.1,y0=curb_outpartisan$conf.int[1],y1=curb_outpartisan$conf.int[2],lwd=3, col="darkgray")
segments(x0=1.9,x1=1.9,y0=defend_nonpartisan$conf.int[1],y1=defend_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=2,x1=2,y0=defend_copartisan$conf.int[1],y1=defend_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=2.1,x1=2.1,y0=defend_outpartisan$conf.int[1],y1=defend_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(2.9,3,3.1),y=c(statement_nonpartisan$estimate,statement_copartisan$estimate,statement_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=2.9,x1=2.9,y0=statement_nonpartisan$conf.int[1],y1=statement_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=3,x1=3,y0=statement_copartisan$conf.int[1],y1=statement_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=3.1,x1=3.1,y0=statement_outpartisan$conf.int[1],y1=statement_outpartisan$conf.int[2],lwd=3, col="darkgray")
legend("topright",pch=c(19,15,17),c("Nonpartisan","Copartisan","Outpartisan"),col=c("#0072ce","#1e407c","darkgray"),cex=1.5)

plot(c(1,2,3),c(diff_nonpartisan$estimate[1]-diff_nonpartisan$estimate[2],
                diff_copartisan$estimate[1]-diff_copartisan$estimate[2],
                diff_outpartisan$estimate[1]-diff_outpartisan$estimate[2]),ylab="mean(Curb) - mean(Defend)", 
     col=c("#0072ce","#1e407c","darkgray"),
     main="Curb v. Defend",cex.main=3,xaxt="n", xlab="", xlim=c(.75,3.25),
     cex.axis=2,cex.lab=2.5,ylim=c(-.5,.1),pch=c(19,15,17),cex=2,bg="black")
mtext(at=c(1,2,3),text=c("Nonpartisan","Copartisan","Outpartisan"),side=1,line=1.5,cex=1.4)
segments(x0=1,x1=1,y0=diff_nonpartisan$conf.int[1],y1=diff_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=2,x1=2,y0=diff_copartisan$conf.int[1],y1=diff_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=3,x1=3,y0=diff_outpartisan$conf.int[1],y1=diff_outpartisan$conf.int[2],lwd=3, col="darkgray")
abline(h=0,col="gray70",lwd=3,lty=2)

plot(c(1,2,3),c(diff_nonpartisan_s$estimate[1]-diff_nonpartisan_s$estimate[2],
                diff_copartisan_s$estimate[1]-diff_copartisan_s$estimate[2],
                diff_outpartisan_s$estimate[1]-diff_outpartisan_s$estimate[2]),ylab="mean(Curb) - mean(Statement)", 
     col=c("#0072ce","#1e407c","darkgray"),
     main="Curb v. Statement",cex.main=3,xaxt="n", xlab="", xlim=c(.75,3.25),
     cex.axis=2,cex.lab=2.5,ylim=c(-.5,.1),pch=c(19,15,17),cex=2,bg="black")
mtext(at=c(1,2,3),text=c("Nonpartisan","Copartisan","Outpartisan"),side=1,line=1.5,cex=1.4)
segments(x0=1,x1=1,y0=diff_nonpartisan_s$conf.int[1],y1=diff_nonpartisan_s$conf.int[2],lwd=3, col="#0072ce")
segments(x0=2,x1=2,y0=diff_copartisan_s$conf.int[1],y1=diff_copartisan_s$conf.int[2],lwd=3, col="#1e407c")
segments(x0=3,x1=3,y0=diff_outpartisan_s$conf.int[1],y1=diff_outpartisan_s$conf.int[2],lwd=3, col="darkgray")
abline(h=0,col="gray70",lwd=3,lty=2)
dev.off()


##MAKE FIGURE 2
d$treat <- d$curb_treatment
d1 <- data.frame(Support=d$support_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Support", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
out$est.bin
pdf("supportBinningOmnibusMeff.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Curb v. Defend",cex.main=1.4)
dev.off()

d$treat <- d$statement_treatment
d1 <- data.frame(Support=d$support_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Support", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
out$est.bin
pdf("supportBinningOmnibusMeffStatement.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Curb v. Statement",cex.main=1.4)
dev.off()


##MAKE FIGURE 3
pdf("DollarStackedBarsLegit_All_Flipped.pdf",width=15,height=15,paper='special') 
par(mar=c(5.1,6, 4.1, 2.1),mfrow=c(3,3), xpd=NA,oma=c(2,3,3,0))
#Nonpartisan: All
a <- c(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T))
aa <- matrix(a,nrow=3,ncol=3)
colnames(aa) <- c("Curb","Defend","Statement")
barplot(aa,cex.names=1.4,las=1,main="",cex.main=1.7,col=c("#0072ce","#1e407c","darkgray"))
mtext(text=c("Average Allocations (in Dollars)"),side=2,line=3,cex=1.4)


#Copartisan: All
a <- c(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T))
aa <- matrix(a,nrow=3,ncol=3)
colnames(aa) <- c("Curb","Defend","Statement")
barplot(aa,cex.names=1.4,las=1,main="",cex.main=1.7,col=c("#0072ce","#1e407c","darkgray"))

#Outpartisan: All
a <- c(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T))
aa <- matrix(a,nrow=3,ncol=3)
colnames(aa) <- c("Curb","Defend","Statement")
barplot(aa,cex.names=1.4,las=1,main="",cex.main=1.7,col=c("#0072ce","#1e407c","darkgray"))

#Nonpartisan: High
a <- c(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T))
aa <- matrix(a,nrow=3,ncol=3)
colnames(aa) <- c("Curb","Defend","Statement")
barplot(aa,cex.names=1.4,las=1,main="",cex.main=1.7,col=c("#0072ce","#1e407c","darkgray"))
mtext(text=c("Average Allocations (in Dollars)"),side=2,line=3,cex=1.4)

#Copartisan: High
a <- c(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T))
aa <- matrix(a,nrow=3,ncol=3)
colnames(aa) <- c("Curb","Defend","Statement")
barplot(aa,cex.names=1.4,las=1,main="",cex.main=1.7,col=c("#0072ce","#1e407c","darkgray"))

#Outpartisan: High
a <- c(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T))
aa <- matrix(a,nrow=3,ncol=3)
colnames(aa) <- c("Curb","Defend","Statement")
barplot(aa,cex.names=1.4,las=1,main="",cex.main=1.7,col=c("#0072ce","#1e407c","darkgray"))

#Nonpartisan: Low
a <- c(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T))
aa <- matrix(a,nrow=3,ncol=3)
colnames(aa) <- c("Curb","Defend","Statement")
barplot(aa,cex.names=1.4,las=1,main="",cex.main=1.7,col=c("#0072ce","#1e407c","darkgray"))
mtext(text=c("Average Allocations (in Dollars)"),side=2,line=3,cex=1.4)


#Copartisan: Low
a <- c(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T))
aa <- matrix(a,nrow=3,ncol=3)
colnames(aa) <- c("Curb","Defend","Statement")
barplot(aa,cex.names=1.4,las=1,main="",cex.main=1.7,col=c("#0072ce","#1e407c","darkgray"))

#Outpartisan: Low
a <- c(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),
       mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T))
aa <- matrix(a,nrow=3,ncol=3)
colnames(aa) <- c("Curb","Defend","Statement")
barplot(aa,cex.names=1.4,las=1,main="",cex.main=1.7,col=c("#0072ce","#1e407c","darkgray"))

legend(x=-5.4,y=-70,ncol=3,c("Incumbent","Challenger","Other Race"), 
       fill=c("#0072ce","#1e407c","darkgray"), title=" ",cex=2,bty='n' )
mtext("                                                                                                           Outpartisan", side = 3, line = -2, outer = TRUE,cex=2)
mtext("    Copartisan", side = 3, line = -2, outer = TRUE,cex=2)
mtext("Nonpartisan                                                                                                      ", side = 3, line = -2, outer = TRUE,cex=2)

mtext("                                                                                                           All Respondents", side = 2, line = .5, outer = TRUE,cex=2)
mtext("     High Legitimacy", side = 2, line = .5, outer = TRUE,cex=2)
mtext("Low Legitimacy                                                                                                      ", side = 2, line = .5, outer = TRUE,cex=2)
dev.off()

#####SUPPLEMENTAL INFORMATION
##Table A1: Summary Statistics
d1 <- data.frame(Job=d$job_dv,Vote=d$vote_dv,Mobilization=d$mobil_dv,Countermobilization=d$counter_dv,Support=d$support_dv,Proposal=d$proposal_dv,IncDollars=d$AMOUNT_1_1,ChalDollars=d$AMOUNT_2_1,OtherDollars=d$AMOUNT_3_1,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
vartable <- sumtable(d1,out='return')
print(xtable(vartable[,c(1,3,4,5,6,7,8)],caption="Summary Statistics, Omnibus Experiment"), include.rownames=FALSE)

##Figure A1
pdf("AllDirectEffects.pdf",width=30,height=13.2,paper='special') 
par(mar=c(5.1,6, 4.1, 2.1),mfrow=c(2,3))
##Job Approval
statement_nonpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$job_dv)
statement_copartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$job_dv)
statement_outpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$job_dv)
curb_nonpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$job_dv)
curb_copartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$job_dv)
curb_outpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$job_dv)
defend_nonpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$job_dv)
defend_copartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$job_dv)
defend_outpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$job_dv)

plot(c(1.9,2,2.1),c(curb_nonpartisan$estimate,curb_copartisan$estimate,curb_outpartisan$estimate),ylab="Job Approval",
     col=c("#0072ce","#1e407c","darkgray"),
     main="Job Approval",cex.main=3,xaxt="n", xlab="", xlim=c(.75,3.25),
     cex.axis=2,cex.lab=2.5,ylim=c(0,1),pch=c(19,15,17),cex=2)
mtext(at=c(1,2,3),text=c("Statement","Curb","Defend"),side=1,line=1.5,cex=1.4)
segments(x0=1.9,x1=1.9,y0=curb_nonpartisan$conf.int[1],y1=curb_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=2,x1=2,y0=curb_copartisan$conf.int[1],y1=curb_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=2.1,x1=2.1,y0=curb_outpartisan$conf.int[1],y1=curb_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(2.9,3,3.1),y=c(defend_nonpartisan$estimate,defend_copartisan$estimate,defend_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=2.9,x1=2.9,y0=defend_nonpartisan$conf.int[1],y1=defend_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=3,x1=3,y0=defend_copartisan$conf.int[1],y1=defend_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=3.1,x1=3.1,y0=defend_outpartisan$conf.int[1],y1=defend_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(.9,1,1.1),y=c(statement_nonpartisan$estimate,statement_copartisan$estimate,statement_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=.9,x1=.9,y0=statement_nonpartisan$conf.int[1],y1=statement_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=1,x1=1,y0=statement_copartisan$conf.int[1],y1=statement_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=1.1,x1=1.1,y0=statement_outpartisan$conf.int[1],y1=statement_outpartisan$conf.int[2],lwd=3, col="darkgray")
legend("topright",pch=c(19,15,17),c("Nonpartisan","Copartisan","Outpartisan"),col=c("#0072ce","#1e407c","darkgray"),cex=1.5)

##Countermobilization
statement_nonpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$counter_dv)
statement_copartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$counter_dv)
statement_outpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$counter_dv)
curb_nonpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$counter_dv)
curb_copartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$counter_dv)
curb_outpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$counter_dv)
defend_nonpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$counter_dv)
defend_copartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$counter_dv)
defend_outpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$counter_dv)

plot(c(1.9,2,2.1),c(curb_nonpartisan$estimate,curb_copartisan$estimate,curb_outpartisan$estimate),ylab="Would Countermobilize Against Incumbent",
     col=c("#0072ce","#1e407c","darkgray"),
     main="Countermobilization",cex.main=3,xaxt="n", xlab="", xlim=c(.75,3.25),
     cex.axis=2,cex.lab=2.5,ylim=c(0,1),pch=c(19,15,17),cex=2)
mtext(at=c(1,2,3),text=c("Statement","Curb","Defend"),side=1,line=1.5,cex=1.4)
segments(x0=1.9,x1=1.9,y0=curb_nonpartisan$conf.int[1],y1=curb_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=2,x1=2,y0=curb_copartisan$conf.int[1],y1=curb_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=2.1,x1=2.1,y0=curb_outpartisan$conf.int[1],y1=curb_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(2.9,3,3.1),y=c(defend_nonpartisan$estimate,defend_copartisan$estimate,defend_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=2.9,x1=2.9,y0=defend_nonpartisan$conf.int[1],y1=defend_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=3,x1=3,y0=defend_copartisan$conf.int[1],y1=defend_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=3.1,x1=3.1,y0=defend_outpartisan$conf.int[1],y1=defend_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(.9,1,1.1),y=c(statement_nonpartisan$estimate,statement_copartisan$estimate,statement_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=.9,x1=.9,y0=statement_nonpartisan$conf.int[1],y1=statement_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=1,x1=1,y0=statement_copartisan$conf.int[1],y1=statement_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=1.1,x1=1.1,y0=statement_outpartisan$conf.int[1],y1=statement_outpartisan$conf.int[2],lwd=3, col="darkgray")
legend("topright",pch=c(19,15,17),c("Nonpartisan","Copartisan","Outpartisan"),col=c("#0072ce","#1e407c","darkgray"),cex=1.5)

##Vote Choice
statement_nonpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$vote_dv)
statement_copartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$vote_dv)
statement_outpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$vote_dv)
curb_nonpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$vote_dv)
curb_copartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$vote_dv)
curb_outpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$vote_dv)
defend_nonpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$vote_dv)
defend_copartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$vote_dv)
defend_outpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$vote_dv)

plot(c(1.9,2,2.1),c(curb_nonpartisan$estimate,curb_copartisan$estimate,curb_outpartisan$estimate),ylab="Vote for Incumbent?",
     col=c("#0072ce","#1e407c","darkgray"),
     main="Vote Choice",cex.main=3,xaxt="n", xlab="", xlim=c(.75,3.25),
     cex.axis=2,cex.lab=2.5,ylim=c(0,1),pch=c(19,15,17),cex=2)
mtext(at=c(1,2,3),text=c("Statement","Curb","Defend"),side=1,line=1.5,cex=1.4)
segments(x0=1.9,x1=1.9,y0=curb_nonpartisan$conf.int[1],y1=curb_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=2,x1=2,y0=curb_copartisan$conf.int[1],y1=curb_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=2.1,x1=2.1,y0=curb_outpartisan$conf.int[1],y1=curb_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(2.9,3,3.1),y=c(defend_nonpartisan$estimate,defend_copartisan$estimate,defend_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=2.9,x1=2.9,y0=defend_nonpartisan$conf.int[1],y1=defend_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=3,x1=3,y0=defend_copartisan$conf.int[1],y1=defend_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=3.1,x1=3.1,y0=defend_outpartisan$conf.int[1],y1=defend_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(.9,1,1.1),y=c(statement_nonpartisan$estimate,statement_copartisan$estimate,statement_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=.9,x1=.9,y0=statement_nonpartisan$conf.int[1],y1=statement_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=1,x1=1,y0=statement_copartisan$conf.int[1],y1=statement_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=1.1,x1=1.1,y0=statement_outpartisan$conf.int[1],y1=statement_outpartisan$conf.int[2],lwd=3, col="darkgray")
legend("topright",pch=c(19,15,17),c("Nonpartisan","Copartisan","Outpartisan"),col=c("#0072ce","#1e407c","darkgray"),cex=1.5)

##Mobilization
statement_nonpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$mobil_dv)
statement_copartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$mobil_dv)
statement_outpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$mobil_dv)
curb_nonpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$mobil_dv)
curb_copartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$mobil_dv)
curb_outpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$mobil_dv)
defend_nonpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$mobil_dv)
defend_copartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$mobil_dv)
defend_outpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$mobil_dv)

plot(c(1.9,2,2.1),c(curb_nonpartisan$estimate,curb_copartisan$estimate,curb_outpartisan$estimate),ylab="Would Mobilize for Incumbent",
     col=c("#0072ce","#1e407c","darkgray"),
     main="Mobilization",cex.main=3,xaxt="n", xlab="", xlim=c(.75,3.25),
     cex.axis=2,cex.lab=2.5,ylim=c(0,1),pch=c(19,15,17),cex=2)
mtext(at=c(1,2,3),text=c("Statement","Curb","Defend"),side=1,line=1.5,cex=1.4)
segments(x0=1.9,x1=1.9,y0=curb_nonpartisan$conf.int[1],y1=curb_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=2,x1=2,y0=curb_copartisan$conf.int[1],y1=curb_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=2.1,x1=2.1,y0=curb_outpartisan$conf.int[1],y1=curb_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(2.9,3,3.1),y=c(defend_nonpartisan$estimate,defend_copartisan$estimate,defend_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=2.9,x1=2.9,y0=defend_nonpartisan$conf.int[1],y1=defend_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=3,x1=3,y0=defend_copartisan$conf.int[1],y1=defend_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=3.1,x1=3.1,y0=defend_outpartisan$conf.int[1],y1=defend_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(.9,1,1.1),y=c(statement_nonpartisan$estimate,statement_copartisan$estimate,statement_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=.9,x1=.9,y0=statement_nonpartisan$conf.int[1],y1=statement_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=1,x1=1,y0=statement_copartisan$conf.int[1],y1=statement_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=1.1,x1=1.1,y0=statement_outpartisan$conf.int[1],y1=statement_outpartisan$conf.int[2],lwd=3, col="darkgray")
legend("topright",pch=c(19,15,17),c("Nonpartisan","Copartisan","Outpartisan"),col=c("#0072ce","#1e407c","darkgray"),cex=1.5)

##Proposal Approval
statement_nonpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$proposal_dv)
statement_copartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$proposal_dv)
statement_outpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$proposal_dv)
curb_nonpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$proposal_dv)
curb_copartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$proposal_dv)
curb_outpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$proposal_dv)
defend_nonpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$proposal_dv)
defend_copartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$proposal_dv)
defend_outpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$proposal_dv)

plot(c(1.9,2,2.1),c(curb_nonpartisan$estimate,curb_copartisan$estimate,curb_outpartisan$estimate),ylab="Proposal Approval",
     col=c("#0072ce","#1e407c","darkgray"),
     main="Proposal Approval",cex.main=3,xaxt="n", xlab="", xlim=c(.75,3.25),
     cex.axis=2,cex.lab=2.5,ylim=c(0,1),pch=c(19,15,17),cex=2)
mtext(at=c(1,2,3),text=c("Statement","Curb","Defend"),side=1,line=1.5,cex=1.4)
segments(x0=1.9,x1=1.9,y0=curb_nonpartisan$conf.int[1],y1=curb_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=2,x1=2,y0=curb_copartisan$conf.int[1],y1=curb_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=2.1,x1=2.1,y0=curb_outpartisan$conf.int[1],y1=curb_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(2.9,3,3.1),y=c(defend_nonpartisan$estimate,defend_copartisan$estimate,defend_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=2.9,x1=2.9,y0=defend_nonpartisan$conf.int[1],y1=defend_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=3,x1=3,y0=defend_copartisan$conf.int[1],y1=defend_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=3.1,x1=3.1,y0=defend_outpartisan$conf.int[1],y1=defend_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(.9,1,1.1),y=c(statement_nonpartisan$estimate,statement_copartisan$estimate,statement_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=.9,x1=.9,y0=statement_nonpartisan$conf.int[1],y1=statement_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=1,x1=1,y0=statement_copartisan$conf.int[1],y1=statement_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=1.1,x1=1.1,y0=statement_outpartisan$conf.int[1],y1=statement_outpartisan$conf.int[2],lwd=3, col="darkgray")
legend("topright",pch=c(19,15,17),c("Nonpartisan","Copartisan","Outpartisan"),col=c("#0072ce","#1e407c","darkgray"),cex=1.5)


##Incumbent Support
statement_nonpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$support_dv)
statement_copartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$support_dv)
statement_outpartisan <- t.test(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$support_dv)
curb_nonpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$support_dv)
curb_copartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$support_dv)
curb_outpartisan <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$support_dv)
defend_nonpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$support_dv)
defend_copartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$support_dv)
defend_outpartisan <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$support_dv)

plot(c(1.9,2,2.1),c(curb_nonpartisan$estimate,curb_copartisan$estimate,curb_outpartisan$estimate),ylab="Incumbent Support",
     col=c("#0072ce","#1e407c","darkgray"),
     main="Incumbent Support",cex.main=3,xaxt="n", xlab="", xlim=c(.75,3.25),
     cex.axis=2,cex.lab=2.5,ylim=c(0,1),pch=c(19,15,17),cex=2)
mtext(at=c(1,2,3),text=c("Statement","Curb","Defend"),side=1,line=1.5,cex=1.4)
segments(x0=1.9,x1=1.9,y0=curb_nonpartisan$conf.int[1],y1=curb_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=2,x1=2,y0=curb_copartisan$conf.int[1],y1=curb_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=2.1,x1=2.1,y0=curb_outpartisan$conf.int[1],y1=curb_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(2.9,3,3.1),y=c(defend_nonpartisan$estimate,defend_copartisan$estimate,defend_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=2.9,x1=2.9,y0=defend_nonpartisan$conf.int[1],y1=defend_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=3,x1=3,y0=defend_copartisan$conf.int[1],y1=defend_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=3.1,x1=3.1,y0=defend_outpartisan$conf.int[1],y1=defend_outpartisan$conf.int[2],lwd=3, col="darkgray")
points(x=c(.9,1,1.1),y=c(statement_nonpartisan$estimate,statement_copartisan$estimate,statement_outpartisan$estimate),pch=c(19,15,17),col=c("#0072ce","#1e407c","darkgray"),cex=2)
segments(x0=.9,x1=.9,y0=statement_nonpartisan$conf.int[1],y1=statement_nonpartisan$conf.int[2],lwd=3, col="#0072ce")
segments(x0=1,x1=1,y0=statement_copartisan$conf.int[1],y1=statement_copartisan$conf.int[2],lwd=3, col="#1e407c")
segments(x0=1.1,x1=1.1,y0=statement_outpartisan$conf.int[1],y1=statement_outpartisan$conf.int[2],lwd=3, col="darkgray")
legend("topright",pch=c(19,15,17),c("Nonpartisan","Copartisan","Outpartisan"),col=c("#0072ce","#1e407c","darkgray"),cex=1.5)
dev.off()


##Table A2
##Nonpartisan
dvs <- c("support_dv","proposal_dv","job_dv","mobil_dv","counter_dv","vote_dv")
m <- matrix(nrow=length(dvs),ncol=7)
colnames(m) <- c("Variable","CurbDefend","CurbDefend.P","CurbStatement","CurbStatement.P","DefendStatement","DefendStatement.P")
for (i in 1:length(dvs)){
        eval(parse(text=paste0("curb_vs_defend <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$",dvs[i],",subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$",dvs[i],")")))
        eval(parse(text=paste0("curb_vs_statement <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$",dvs[i],",subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$",dvs[i],")")))
        eval(parse(text=paste0("defend_vs_statement <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$",dvs[i],",subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$",dvs[i],")")))
        m[i,1] <- dvs[i]
        m[i,2] <- unname(format(round((curb_vs_defend$estimate[1]-curb_vs_defend$estimate[2]),2), nsmall = 2))
        if (format(round(curb_vs_defend$p.value,2), nsmall = 2)=="0.00"){
                m[i,3] <- "< 0.01"
        } else {
                m[i,3] <- format(round(curb_vs_defend$p.value,2), nsmall = 2)
        }
        m[i,4] <- unname(format(round((curb_vs_statement$estimate[1]-curb_vs_statement$estimate[2]),2), nsmall = 2))
        if (format(round(curb_vs_statement$p.value,2), nsmall = 2)=="0.00"){
                m[i,5] <- "< 0.01"
        } else {
                m[i,5] <- format(round(curb_vs_statement$p.value,2), nsmall = 2)
        }
        m[i,6] <- unname(format(round((defend_vs_statement$estimate[1]-defend_vs_statement$estimate[2]),2), nsmall = 2))
        if (format(round(defend_vs_statement$p.value,2), nsmall = 2)=="0.00"){
                m[i,7] <- "< 0.01"
        } else {
                m[i,7] <- format(round(defend_vs_statement$p.value,2), nsmall = 2)
        }
}
print(xtable(m), include.rownames=FALSE)


##Copartisan
m <- matrix(nrow=length(dvs),ncol=7)
colnames(m) <- c("Variable","CurbDefend","CurbDefend.P","CurbStatement","CurbStatement.P","DefendStatement","DefendStatement.P")
for (i in 1:length(dvs)){
        eval(parse(text=paste0("curb_vs_defend <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$",dvs[i],",subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$",dvs[i],")")))
        eval(parse(text=paste0("curb_vs_statement <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$",dvs[i],",subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$",dvs[i],")")))
        eval(parse(text=paste0("defend_vs_statement <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$",dvs[i],",subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$",dvs[i],")")))
        m[i,1] <- dvs[i]
        m[i,2] <- unname(format(round((curb_vs_defend$estimate[1]-curb_vs_defend$estimate[2]),2), nsmall = 2))
        if (format(round(curb_vs_defend$p.value,2), nsmall = 2)=="0.00"){
                m[i,3] <- "< 0.01"
        } else {
                m[i,3] <- format(round(curb_vs_defend$p.value,2), nsmall = 2)
        }
        m[i,4] <- unname(format(round((curb_vs_statement$estimate[1]-curb_vs_statement$estimate[2]),2), nsmall = 2))
        if (format(round(curb_vs_statement$p.value,2), nsmall = 2)=="0.00"){
                m[i,5] <- "< 0.01"
        } else {
                m[i,5] <- format(round(curb_vs_statement$p.value,2), nsmall = 2)
        }
        m[i,6] <- unname(format(round((defend_vs_statement$estimate[1]-defend_vs_statement$estimate[2]),2), nsmall = 2))
        if (format(round(defend_vs_statement$p.value,2), nsmall = 2)=="0.00"){
                m[i,7] <- "< 0.01"
        } else {
                m[i,7] <- format(round(defend_vs_statement$p.value,2), nsmall = 2)
        }
}
print(xtable(m), include.rownames=FALSE)


##Outpartisan
m <- matrix(nrow=length(dvs),ncol=7)
colnames(m) <- c("Variable","CurbDefend","CurbDefend.P","CurbStatement","CurbStatement.P","DefendStatement","DefendStatement.P")
for (i in 1:length(dvs)){
        eval(parse(text=paste0("curb_vs_defend <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$",dvs[i],",subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$",dvs[i],")")))
        eval(parse(text=paste0("curb_vs_statement <- t.test(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$",dvs[i],",subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$",dvs[i],")")))
        eval(parse(text=paste0("defend_vs_statement <- t.test(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$",dvs[i],",subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$",dvs[i],")")))
        m[i,1] <- dvs[i]
        m[i,2] <- unname(format(round((curb_vs_defend$estimate[1]-curb_vs_defend$estimate[2]),2), nsmall = 2))
        if (format(round(curb_vs_defend$p.value,2), nsmall = 2)=="0.00"){
                m[i,3] <- "< 0.01"
        } else {
                m[i,3] <- format(round(curb_vs_defend$p.value,2), nsmall = 2)
        }
        m[i,4] <- unname(format(round((curb_vs_statement$estimate[1]-curb_vs_statement$estimate[2]),2), nsmall = 2))
        if (format(round(curb_vs_statement$p.value,2), nsmall = 2)=="0.00"){
                m[i,5] <- "< 0.01"
        } else {
                m[i,5] <- format(round(curb_vs_statement$p.value,2), nsmall = 2)
        }
        m[i,6] <- unname(format(round((defend_vs_statement$estimate[1]-defend_vs_statement$estimate[2]),2), nsmall = 2))
        if (format(round(defend_vs_statement$p.value,2), nsmall = 2)=="0.00"){
                m[i,7] <- "< 0.01"
        } else {
                m[i,7] <- format(round(defend_vs_statement$p.value,2), nsmall = 2)
        }
}
print(xtable(m), include.rownames=FALSE)

##Figure A2
d$treat <- d$curb_treatment
d1 <- data.frame(Job=d$job_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Job", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("jobBinningOmnibusMeff.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Job Approval",cex.main=1.4)
dev.off()

d1 <- data.frame(Countermobilization=d$counter_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Countermobilization", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("counterBinningOmnibusMeff.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",main="Countermobilization",cex.main=1.4)
dev.off()

d1 <- data.frame(Vote=d$vote_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Vote", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("voteBinningOmnibusMeff.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Vote Intention",cex.main=1.4)
dev.off()

d1 <- data.frame(Mobilization=d$mobil_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Mobilization", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("mobilBinningOmnibusMeff.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Mobilization",cex.main=1.4)
dev.off()

d1 <- data.frame(Proposal=d$proposal_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Proposal", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("proposalBinningOmnibusMeff.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",main="Proposal Approval",cex.main=1.4)
dev.off()

d1 <- data.frame(Support=d$support_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Support", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
out$est.bin
pdf("supportBinningOmnibusMeff.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Curb v. Defend",cex.main=1.4)
dev.off()


##Figure A3
d$treat <- d$statement_treatment
d1 <- data.frame(Support=d$support_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Support", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("supportBinningOmnibusMeffStatement.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Curb v. Statement",cex.main=1.4)
dev.off()

d1 <- data.frame(Job=d$job_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Job", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("jobBinningOmnibusMeffStatement.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Job Approval",cex.main=1.4)
dev.off()

d1 <- data.frame(Vote=d$vote_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Vote", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("voteBinningOmnibusMeffStatement.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Vote Intention",cex.main=1.4)
dev.off()

d1 <- data.frame(Mobilization=d$mobil_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Mobilization", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("mobilBinningOmnibusMeffStatement.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Mobilization",cex.main=1.4)
dev.off()

d1 <- data.frame(Countermobilization=d$counter_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Countermobilization", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("counterBinningOmnibusMeffStatement.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",main="Countermobilization",cex.main=1.4)
dev.off()

d1 <- data.frame(Proposal=d$proposal_dv,Curb=d$treat,Legitimacy=d$legit)
out <- interflex(Y = "Proposal", D = "Curb", X = "Legitimacy", data = d1, 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("proposalBinningOmnibusMeffStatement.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",main="Proposal Approval",cex.main=1.4)
dev.off()


##Figure A4
d$treat <- d$curb_treatment
d1 <- data.frame(Job=d$job_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Job", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"),
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("jobBinningOmnibusMeffControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Job Approval",cex.main=1.4)
dev.off()

d1 <- data.frame(Vote=d$vote_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Vote", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("voteBinningOmnibusMeffControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Vote Intention",cex.main=1.4)
dev.off()

d1 <- data.frame(Mobilization=d$mobil_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Mobilization", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("mobilBinningOmnibusMeffControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Mobilization",cex.main=1.4)
dev.off()


d1 <- data.frame(Countermobilization=d$counter_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Countermobilization", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("counterBinningOmnibusMeffControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",main="Countermobilization",cex.main=1.4)
dev.off()

d1 <- data.frame(Support=d$support_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Support", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("supportBinningOmnibusMeffControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Incumbent Support",cex.main=1.4)
dev.off()

d1 <- data.frame(Proposal=d$proposal_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Proposal", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("proposalBinningOmnibusMeffControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Defending)",
     xlab="Legitimacy",main="Proposal Approval",cex.main=1.4)
dev.off()

##Figure A5
d$treat <- d$statement_treatment
d1 <- data.frame(Job=d$job_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Job", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("jobBinningOmnibusMeffStatementControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Job Approval",cex.main=1.4)
dev.off()

d1 <- data.frame(Vote=d$vote_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Vote", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("voteBinningOmnibusMeffStatementControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Vote Intention",cex.main=1.4)
dev.off()

d1 <- data.frame(Mobilization=d$mobil_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Mobilization", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("mobilBinningOmnibusMeffStatementControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Mobilization",cex.main=1.4)
dev.off()


d1 <- data.frame(Countermobilization=d$counter_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Countermobilization", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("counterBinningOmnibusMeffStatementControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",main="Countermobilization",cex.main=1.4)
dev.off()

d1 <- data.frame(Support=d$support_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Support", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("supportBinningOmnibusMeffStatementControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",ylim=c(-.5,.2),main="Incumbent Support",cex.main=1.4)
dev.off()

d1 <- data.frame(Proposal=d$proposal_dv,Curb=d$treat,Legitimacy=d$legit,educ_rescale=d$educ_rescale, political_interest=d$political_interest, scjob_rescaled=d$scjob_rescaled, female=d$female, nonwhite=d$nonwhite, age_rescale=d$age_rescale, ideology_rescale=d$ideology_rescale)
out <- interflex(Y = "Proposal", D = "Curb", X = "Legitimacy", data = d1, Z=c("educ_rescale","political_interest","scjob_rescaled","female","nonwhite","age_rescale","ideology_rescale"), 
                 estimator = "binning",na.rm=T, vcov.type = "robust", 
                 main = "Marginal Effects")
pdf("proposalBinningOmnibusMeffStatementControls.pdf",width=6,height=6,paper='special') 
plot(out,theme.bw = TRUE, show.grid = FALSE,Xdistr = "density",bin.labs = FALSE,xlim=c(0,1),
     ylab="Marginal Effect of Curbing (vs. Issuing Statement)",
     xlab="Legitimacy",main="Proposal Approval",cex.main=1.4)
dev.off()


##Table A3
m1 <- matrix(NA,nrow=15,ncol=5)
colnames(m1) <- c("Stance","Partisanship","Incumbent","Challenger","Other Race")
m1[1,1] <- "Statement"
m1[7,1] <- "Statement"
m1[8,1] <- "Statement"
m1[9,1] <- "Statement"
m1[7,2] <- "Nonpartisan"
m1[10,2] <- "Nonpartisan"
m1[13,2] <- "Nonpartisan"
m1[2,1] <- "Curb"
m1[10,1] <- "Curb"
m1[11,1] <- "Curb"
m1[12,1] <- "Curb"
m1[8,2] <- "Copartisan"
m1[11,2] <- "Copartisan"
m1[14,2] <- "Copartisan"
m1[3,1] <- "Defend"
m1[13,1] <- "Defend"
m1[14,1] <- "Defend"
m1[15,1] <- "Defend"
m1[9,2] <- "Outpartisan"
m1[12,2] <- "Outpartisan"
m1[15,2] <- "Outpartisan"
m1[4,2] <- "Nonpartisan"
m1[5,2] <- "Copartisan"
m1[6,2] <- "Outpartisan"

m1[1,3] <- round(mean(subset(d,stance_reorder_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m1[1,4] <- round(mean(subset(d,stance_reorder_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m1[1,5] <- round(mean(subset(d,stance_reorder_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m1[2,3] <- round(mean(subset(d,stance_reorder_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m1[2,4] <- round(mean(subset(d,stance_reorder_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m1[2,5] <- round(mean(subset(d,stance_reorder_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m1[3,3] <- round(mean(subset(d,stance_reorder_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m1[3,4] <- round(mean(subset(d,stance_reorder_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m1[3,5] <- round(mean(subset(d,stance_reorder_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m1[4,3] <- round(mean(subset(d,copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m1[4,4] <- round(mean(subset(d,copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m1[4,5] <- round(mean(subset(d,copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m1[5,3] <- round(mean(subset(d,copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m1[5,4] <- round(mean(subset(d,copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m1[5,5] <- round(mean(subset(d,copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m1[6,3] <- round(mean(subset(d,copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m1[6,4] <- round(mean(subset(d,copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m1[6,5] <- round(mean(subset(d,copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m1[7,3] <- round(mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m1[7,4] <- round(mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m1[7,5] <- round(mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m1[8,3] <- round(mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m1[8,4] <- round(mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m1[8,5] <- round(mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m1[9,3] <- round(mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m1[9,4] <- round(mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m1[9,5] <- round(mean(subset(d,stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m1[10,3] <- round(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m1[10,4] <- round(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m1[10,5] <- round(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m1[11,3] <- round(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m1[11,4] <- round(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m1[11,5] <- round(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m1[12,3] <- round(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m1[12,4] <- round(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m1[12,5] <- round(mean(subset(d,stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m1[13,3] <- round(mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m1[13,4] <- round(mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m1[13,5] <- round(mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m1[14,3] <- round(mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m1[14,4] <- round(mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m1[14,5] <- round(mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m1[15,3] <- round(mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m1[15,4] <- round(mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m1[15,5] <- round(mean(subset(d,stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

print(xtable(m1[7:15,]), include.rownames=FALSE)

##Table A4
m_low <- matrix(NA,nrow=15,ncol=5)
colnames(m_low) <- c("Stance","Partisanship","Incumbent","Challenger","Other Race")
m_low[1,1] <- "Statement"
m_low[7,1] <- "Statement"
m_low[8,1] <- "Statement"
m_low[9,1] <- "Statement"
m_low[7,2] <- "Nonpartisan"
m_low[10,2] <- "Nonpartisan"
m_low[13,2] <- "Nonpartisan"
m_low[2,1] <- "Curb"
m_low[10,1] <- "Curb"
m_low[11,1] <- "Curb"
m_low[12,1] <- "Curb"
m_low[8,2] <- "Copartisan"
m_low[11,2] <- "Copartisan"
m_low[14,2] <- "Copartisan"
m_low[3,1] <- "Defend"
m_low[13,1] <- "Defend"
m_low[14,1] <- "Defend"
m_low[15,1] <- "Defend"
m_low[9,2] <- "Outpartisan"
m_low[12,2] <- "Outpartisan"
m_low[15,2] <- "Outpartisan"
m_low[4,2] <- "Nonpartisan"
m_low[5,2] <- "Copartisan"
m_low[6,2] <- "Outpartisan"

m_low[1,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_low[1,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_low[1,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_low[2,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_low[2,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_low[2,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_low[3,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_low[3,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_low[3,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m_low[4,3] <- round(mean(subset(d,legitTercile==1 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_low[4,4] <- round(mean(subset(d,legitTercile==1 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_low[4,5] <- round(mean(subset(d,legitTercile==1 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_low[5,3] <- round(mean(subset(d,legitTercile==1 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_low[5,4] <- round(mean(subset(d,legitTercile==1 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_low[5,5] <- round(mean(subset(d,legitTercile==1 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_low[6,3] <- round(mean(subset(d,legitTercile==1 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_low[6,4] <- round(mean(subset(d,legitTercile==1 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_low[6,5] <- round(mean(subset(d,legitTercile==1 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m_low[7,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_low[7,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_low[7,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_low[8,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_low[8,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_low[8,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_low[9,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_low[9,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_low[9,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m_low[10,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_low[10,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_low[10,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_low[11,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_low[11,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_low[11,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_low[12,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_low[12,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_low[12,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m_low[13,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_low[13,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_low[13,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_low[14,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_low[14,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_low[14,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_low[15,3] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_low[15,4] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_low[15,5] <- round(mean(subset(d,legitTercile==1 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m_high <- matrix(NA,nrow=15,ncol=5)
colnames(m_high) <- c("Stance","Partisanship","Incumbent","Challenger","Other Race")
m_high[1,1] <- "Statement"
m_high[7,1] <- "Statement"
m_high[8,1] <- "Statement"
m_high[9,1] <- "Statement"
m_high[7,2] <- "Nonpartisan"
m_high[10,2] <- "Nonpartisan"
m_high[13,2] <- "Nonpartisan"
m_high[2,1] <- "Curb"
m_high[10,1] <- "Curb"
m_high[11,1] <- "Curb"
m_high[12,1] <- "Curb"
m_high[8,2] <- "Copartisan"
m_high[11,2] <- "Copartisan"
m_high[14,2] <- "Copartisan"
m_high[3,1] <- "Defend"
m_high[13,1] <- "Defend"
m_high[14,1] <- "Defend"
m_high[15,1] <- "Defend"
m_high[9,2] <- "Outpartisan"
m_high[12,2] <- "Outpartisan"
m_high[15,2] <- "Outpartisan"
m_high[4,2] <- "Nonpartisan"
m_high[5,2] <- "Copartisan"
m_high[6,2] <- "Outpartisan"

m_high[1,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_high[1,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_high[1,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_high[2,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_high[2,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_high[2,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_high[3,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_high[3,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_high[3,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m_high[4,3] <- round(mean(subset(d,legitTercile==3 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_high[4,4] <- round(mean(subset(d,legitTercile==3 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_high[4,5] <- round(mean(subset(d,legitTercile==3 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_high[5,3] <- round(mean(subset(d,legitTercile==3 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_high[5,4] <- round(mean(subset(d,legitTercile==3 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_high[5,5] <- round(mean(subset(d,legitTercile==3 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_high[6,3] <- round(mean(subset(d,legitTercile==3 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_high[6,4] <- round(mean(subset(d,legitTercile==3 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_high[6,5] <- round(mean(subset(d,legitTercile==3 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m_high[7,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_high[7,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_high[7,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_high[8,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_high[8,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_high[8,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_high[9,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_high[9,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_high[9,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==1 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m_high[10,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_high[10,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_high[10,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_high[11,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_high[11,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_high[11,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_high[12,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_high[12,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_high[12,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==2 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

m_high[13,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_1_1,na.rm=T),2)
m_high[13,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_2_1,na.rm=T),2)
m_high[13,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==1)$AMOUNT_3_1,na.rm=T),2)
m_high[14,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_1_1,na.rm=T),2)
m_high[14,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_2_1,na.rm=T),2)
m_high[14,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==2)$AMOUNT_3_1,na.rm=T),2)
m_high[15,3] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_1_1,na.rm=T),2)
m_high[15,4] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_2_1,na.rm=T),2)
m_high[15,5] <- round(mean(subset(d,legitTercile==3 & stance_reorder_treatment==3 & copartisan_treatment==3)$AMOUNT_3_1,na.rm=T),2)

print(xtable(cbind(m_low[7:15,],m_high[7:15,])), include.rownames=FALSE)